home *** CD-ROM | disk | FTP | other *** search
/ Aminet 6 / Aminet 6 - June 1995.iso / Aminet / docs / mags / ARTv1i1A.lha / smake.lha / Smakefile < prev    next >
Encoding:
Makefile  |  1995-03-16  |  3.0 KB  |  128 lines

  1. # SMakefile for SAS/C
  2. # Copyright © 1995 Osma Ahvenlampi. Freely distributable.
  3.  
  4. # $Id$
  5. # $Log$
  6.  
  7. # Project files
  8.  
  9. PROG=        xxx
  10. SRCS=        $(PROG).c
  11. OBJS=        $(PROG)_Cat.o $(PROG).o
  12. INCS=        $(PROG).h
  13. MISC=        SMakefile
  14. LIBS=
  15. DEBUGLIBS=    LIB:debug.lib
  16.  
  17. # Files to delete on "make clean"
  18.  
  19. JUNK=        \#?.(o|map|lnk|gst) SCOPTIONS
  20.  
  21. # Build options
  22.  
  23. CFLAGS=        DEBUG=LINE OPTIMIZE NOSTACKCHECK
  24. DCFLAGS=    DEBUG=SYMBOLFLUSH NOOPTIMIZE DEF=DEBUG
  25. LDFLAGS=    STRIPDEBUG
  26. IDIRS=
  27. DEFS=
  28.  
  29. # Compiler defaults
  30.  
  31. SCOPTIONS=    STRINGMERGE PARAMETERS=REGISTERS ERRORREXX \
  32.         SMALLCODE SMALLDATA NOVERSION UTILITYLIBRARY \
  33.         NOICONS ONERROR=CONTINUE NOGENPROTOTYPEDEFS \
  34.         STRINGSCONST UNSIGNEDCHARS \
  35.         $(IDIRS) $(DEFS) GST=$(PROG).gst
  36.  
  37. # Programs used
  38.  
  39. RM=        delete quiet
  40. CP=        copy
  41. CAT=        type
  42. TAGS=        ctags
  43. VER=        ver
  44. CI=        ci
  45. MAKE=        smake
  46. CATCOMP=    flexcat
  47.  
  48. # current build version from the 'VERSION' file
  49. VERSION=    `$(CAT) VERSION`
  50.         
  51. # Standard targets
  52.  
  53. # make the binary with debug options
  54. test:
  55.     $(MAKE) "CFLAGS=$(DCFLAGS)" "LIBS=$(DEBUGLIBS)" "LDFLAGS=" $(PROG)
  56.  
  57. # make the program using "distribution" options.
  58. all:        $(PROG)
  59.  
  60. # Build rules
  61.  
  62. # first rebuild the GST file if necessary
  63. $(PROG):    $(PROG).gst version.o $(OBJS)
  64.     $(CC) version.o $(OBJS) LINK TO $@ BATCH $(LIBS) $(LDFLAGS) $(CFLAGS)
  65.     $(VER) # bump revision for next link
  66.  
  67. # copy SCOPTIONS variable to file
  68. SCOPTIONS:    SMakefile
  69.     $(CP) TO $@ <FROM <
  70. $(SCOPTIONS)
  71. <
  72.  
  73. # create project GST file. gst.c #includes all used headers.
  74. $(PROG).gst:    SCOPTIONS gst.c $(INCS)
  75.     GST `cd`/$@ UNLOAD
  76.     -@$(RM) $@ >NIL:
  77.     SC NOOBJNAME NOGST MAKEGST=$@ gst.c
  78.  
  79. # localisation. Create default strings and locale lookup source using
  80. # FlexCat and the catalog description file.
  81. # Compile said source using hook options (since custom BOOPSI gadgets
  82. # might also be localised).
  83. $(PROG)_Cat.c:    $(PROG).cd
  84.     $(CATCOMP) $(PROG).cd $(PROG)_Cat.c=C_c_V21.sd $(PROG)_Cat.h=C_h.sd
  85.  
  86. $(PROG)_Cat.o:    $(PROG)_Cat.c
  87.     $(CC) $(CFLAGS) $(HOOKFLAGS) $<
  88.  
  89. # create version.c if it doesn't exist. Defines three global variables:
  90. # VersionID is the AmigaDOS $VER: string.
  91. # Version is the version number.
  92. # CompileDate is the build date.
  93. # use these instead of hardcoded variables or preprocessor #defines
  94. # within your source code!
  95. version.c:
  96.     $(CP) TO $@ <FROM <
  97. const char VersionID[] = "$$VER: $(PROG) " VERSION " " __AMIGADATE__;
  98. const char Version[] = VERSION;
  99. const char CompileDate[] = __AMIGADATE__;
  100. <
  101.  
  102. # recompile version.c if any of the other source files have changed.
  103. # first make sure VERSION exists, but don't bump it.
  104. version.o:    version.c $(SRCS) $(INCS)
  105.     $(VER) -n # make sure VERSION exists
  106.     $(CC) NODEBUG DEF=VERSION="$(VERSION)" version.c
  107.  
  108. # store current source version in the RCS database.
  109. rcs:
  110.     $(CI) -l$(VERSION) $(SRCS) $(INCS) $(MISC)
  111.  
  112. # make a 'tags' file from the sources for function reference.
  113. tags:        $(SRCS) $(INCS)
  114.     $(TAGS) $(SRCS) $(INCS)
  115.  
  116. # generate prototypes for all functions to 'protos.h'.
  117. proto:        $(PROG).gst
  118.     $(CC) $(SRCS) GENPROTO
  119.     $(CAT) \#?_protos.h >protos.h
  120.     $(RM) \#?_protos.h
  121.  
  122. # clean the directory of recreatable files.
  123. clean:
  124.     $(RM) $(JUNK)
  125.  
  126. clobber:    clean
  127.     $(RM) $(PROG)
  128.